<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script type="text/javascript" src="${ctx}/commons/js/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css" href="${ctx}/commons/js/uploadify/uploadify.css" rel="stylesheet"></link>
<style type="text/css">
	li{
		padding-top:8px;
	}
	.st{
	 display:none;
	}
</style>
<script type="text/javascript">
     var requestUrl="http://${basePath}:${port}${ctx}/business/projectmanage/input?projectId=${project.id}&r="+new Date().getTime();
</script>
<form name="addProjectsDataForm" id="addProjectsDataForm" method="post" action="${ctx}/business/projectmanage/save" >
	<input type="hidden" name="id" id="projectIdHidden" value="${project.id}"/>
	<input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/>
	<table class="infoTable">
		<tbody>
		<tr>
			<th align="right" width="15%">项目名称</th>
			<td width="35%">
				<input name="name" style="width:180px;" maxlength="50" class="easyui-validatebox" prompt="" data-options="required:true,validType:['isNull','validProjName[\'${ctx }\']']" value="${project.name}"/>
			</td>
			<th align="right" width="15%">项目预算(元)</th>
			<td colspan="1">
				<input id="budgetAmount" name="budgetAmount" style="width:180px;" maxlength="20" class="easyui-validatebox" prompt="" data-options="required:true,validType:['priceDecimal']" value="<fmt:formatNumber value="${project.budgetAmount}" type="currency" pattern=".00#"/>"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">委托单位</th>
			<td width="35%">
				<input name="agentName" style="width:180px;" class="easyui-validatebox" readonly="readonly" prompt="" value="${user.loginName}"/>
			</td>
			<th align="right" width="15%">采购单位</th>
			<td width="35%">
				<input name="buyName" style="width:180px;" class="easyui-validatebox" prompt="" data-options="required:true,validType:['isNull']" value="${project.buyName}"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">采购单位地址</th>
			<td width="85%" colspan="3">
				<input name="address" style="width:511px;" class="easyui-validatebox" prompt="" data-options="required:true,validType:['isBlank']" value="${project.address}"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">经办人</th>
			<td width="35%">
				<input name="operater" style="width:180px;" class="easyui-validatebox" prompt="" data-options="required:true,validType:['isNull']" value="${project.operater}"/>
			</td>
			<th align="right" width="15%">联系电话</th>
			<td width="35%">
				<input name="contactTel" style="width:180px;" class="easyui-validatebox" prompt="" data-options="required:true,validType:['phone']" value="${project.contactTel}"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">QQ号</th>
			<td width="35%">
				<input name="qq" style="width:180px;" class="easyui-validatebox" prompt="" data-options="required:true,validType:['number']" value="${project.qq}"/>
			</td>
			<th align="right" width="15%">项目类型</th>
			<td width="36%">
				<input name="catagoryId" id="catagoryId" class="easyui-combobox" prompt="" style="width:180px" data-options="required:true,valueField:'id',textField:'name',url:'${ctx}/business/projectmanage/getProjectTypes',editable:false" value="${project.catagoryId}"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">资金来源</th>
			<td width="36%">
				<input name="fundFrom" class="easyui-combobox" prompt="" style="width:180px" data-options="required:true,valueField:'value',textField:'name',url:'${ctx}/business/projectmanage/getFundFroms',editable:false" value="${project.fundFrom}"/>
			</td>
			<th class="key" cosplan="2">交易方式:</th>
			<td>
				<input name="tradeType" readonly="readonly" class="easyui-combobox" prompt="" style="width:180px" data-options="required:true,valueField:'value',textField:'name',url:'${ctx}/business/projectmanage/getTradeType',editable:false" value="${project.tradeType==null?'J':project.tradeType}"/>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">社会信用代码</th>
			<td width="36%">
			   <input name="organizationCode" id="organizationCode" style="width:180px;" class="easyui-validatebox" data-options="required:true"  value="${project.organizationCode}"/>
			</td>
			
		</tr>
		<tr>
			<th class="key">竞价发起人:</th>
			<td colspan="3">
				<input type="radio"  class="textField" name="auditable" ${project.auditable!=null?"disabled":""} value="true" ${project.auditable==null||project.auditable==true?"checked":"" } onclick="isEvaluatBidClick(1)"/> 公共资源交易中心
				
				<input type="radio"  class="textField" name="auditable" ${project.auditable!=null?"disabled":""} value="false" ${project.auditable==false?"checked":"" } onclick="isEvaluatBidClick(0)"/> 采购人
				<font color="red"> 注：此项不可修改！</font>
			</td>
		</tr>

		<tr id="noBidForm" class="${project.auditable==null||project.auditable==true?"st":"" }">
			<th align="right" width="15%">分管领导:</th>
			<td width="30%">
				<input name="manageLeader" id="manageLeader" style="width:180px;" class="easyui-validatebox"  value="${project.manageLeader}"/>
			</td>
			<th align="right" width="15%">项目负责人:</th>
			<td width="30%">
				<input name="manageName" id="manageName" style="width:180px;" class="easyui-validatebox" value="${project.manageName}"/>
			</td>
		</tr>
		<tr id="noBidForm1" class="${project.auditable==null||project.auditable==true?"st":"" }">
			<th align="right" width="15%">手机号码:</th>
			<td width="30%">
		      <input  name="phoneNumber" id="phoneNumber"  style="width:180px;" class="easyui-validatebox" value="${project.phoneNumber}"/>	
			</td>
			
		</tr>
		 <tr>
			<th align="right" width="15%">付款方式</th>
			<td width="35%" colspan="3">
				<textarea rows="3" cols="75" id="payType" name="payType" data-options="required:true,validType:['isNull']" 
				oninput="checkLength('payTypeRemarkError',200,'payType')" onpropertychange="checkLength('payTypeRemarkError',200,'payType')" onkeyup="checkLength('payTypeRemarkError',200,'payType')">${project.payType}</textarea>
				<font color="red"><br />注：200个字符以内，还可以输入<span class="input_font" id="payTypeRemarkError">200</span>个字符</font>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">采购内容</th>
			<td colspan="3">
				<textarea rows="5" cols="75" id="buyContent" name="buyContent" data-options="required:true" 
				oninput="checkLength('buyContentRemarkError',200,'buyContent')" onpropertychange="checkLength('buyContentRemarkError',200,'buyContent')" onkeyup="checkLength('buyContentRemarkError',200,'buyContent')">${project.buyContent}</textarea>
				<font color="red"><br />注：200个字符以内，还可以输入<span class="input_font" id="buyContentRemarkError">200</span>个字符</font>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">交易申报表</th>
			<td style="border-right: none" width="36%">
				<div id="fileQueue1" class="fileQueue" style="margin: 10px 0px 0px 10px">
					<input type="file" name="uploadify" id="dealDeclareUpload" class="upload"/>
					<p style="color: #aaaaaa;width: auto">
		1、按住Ctrl可选择多个文件上传;<br/>
		2、可上传jpg,png,gif,bmp,pdf类型文件<br/>
		</p>
				</div>
			</td>
			<td style="border-left: none" colspan="2">
				<c:forEach items="${resList}" var="res">
					<c:if test="${res.functionFlog==1}">
						<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
					</c:if>
				</c:forEach>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%" id="proRequest">项目需求</th>
			<td style="border-right: none" width="36%">
				<div id="fileQueue2" class="fileQueue" style="margin: 10px 0px 0px 10px">
					<input type="file" name="uploadify" id="proDemandUpload"  class="upload"/>
					<a href="javascript:void(0);" onclick="#" id="tip" class="easyui-linkbutton" iconCls="icon-help" plain="true" title="提供交易项目所需资料(对投标人资格、业绩要求) 及对项目的其他要求(电子档) rar world Excel CAD 图片  PDF 大小50MB"></a>
					<p style="color: #aaaaaa;width: auto">
		1、按住Ctrl可选择多个文件上传;<br/>
		2、可上传*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws类型文件<br/>
		</p>
				</div>
			</td>
			<td style="border-left: none" colspan="2">
				<c:forEach items="${resList}" var="res">
					 <c:if test="${res.functionFlog==2}">
						<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
					</c:if>
				</c:forEach>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">其他资料</th>
			<td style="border-right: none" width="36%">
				<div id="fileQueue3" class="fileQueue" style="margin: 10px 0px 0px 10px;float: left">
					<input type="file" name="uploadify" id="otherUpload"  class="upload"/>
					<a href="javascript:void(0);" onclick="#" id="tip" class="easyui-linkbutton" iconCls="icon-help" plain="true" title="提供项目的清单、参数、图纸等其他相关资料"></a>
					<p style="color: #aaaaaa;width: auto">
		1、按住Ctrl可选择多个文件上传;<br/>
		2、可上传*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws类型文件<br/>
		</p>
				</div>
			</td>
			<td style="border-left: none" colspan="2">
				<c:forEach items="${resList}" var="res">
					<c:if test="${res.functionFlog==3}">
						<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
					</c:if>
				</c:forEach>
			</td>
		</tr>
		</tbody>
	</table>
	<input id="commitTypeHidden" type="hidden" name="commitType" value=""/>
	<input id="noCompetReasonDesc" type="hidden" name="noCompetReason" value=""/>
</form>
<script type="text/javascript">

	$("#catagoryId").combobox({onSelect : function(){
			var value = $("#catagoryId").combobox("getValue") ;
			if(value=="297edff854087daf01540d5cef8b0004"){//工程类
				$("#proRequest").text("清单图纸等资料");
			}else{
				$("#proRequest").text("项目需求");
			}
			//alert(value);	
		}
	});
  
	/*是否评标点击事件*/
	function isEvaluatBidClick(isBid) {
	    if(isBid==0){//不评标,显示
	    	$("#noBidForm").removeClass("st");
            $("#noBidForm1").removeClass("st");
           
	    }else{//评标,不显示
	    	$("#phoneNumber").removeAttr("required");
	    	$("#noBidForm").addClass("st");
            $("#noBidForm1").addClass("st");
            
	    }
   	}
   
	$(function(){
	   // parent.$('#addEntityBt').hide();
		var resIds = "";
		<c:forEach items="${resList}" var="res">
		resIds += ",${res.id}";
		</c:forEach>
		$('#budgetMenuData').val(resIds);
		
		/**
		 *交易申报表
		 *
		**/
		$("#dealDeclareUpload").uploadify({//交易申报表
			'height'        : 27,   
            'width'         : 80,    
            'buttonText'    : '选择附件',
            'queueID': 'fileQueue1',//队列的ID
            'queueSizeLimit':5,// 附件附列长度
			'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
			'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}?functionFlog=1',// 上传时请求的后台处理的controller
			'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
			'method':'post',  
			'folder': '',
			'preventCaching' : true,
			'fileTypeExts' :'*.jpg;*.png;*.gif;*.bmp;*.pdf',
			'auto': true,
			'multi': true,//是否可多选
			'removeCompleted' : false,
			'successTimeout' : 55555,
			'onUploadSuccess':function(file, data, response){
				 $('#' + file.id).find('.data').html(' 上传完毕');
				$('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
				var cancel=$('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
				if (cancel) {
				   cancel.attr("rel", data);
				   cancel.click(function () {
					   //alert(2);
					   var cancelData = cancel.attr("rel");
		               var  budgetMenuData = $('#budgetMenuData').val();
		               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
		               if(index != -1){
		            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
		            	   $('#budgetMenuData').val(budgetMenuData);
		               }
				   });
				}
			},
			'onSelectError':function(file, errorCode, errorMsg){
				switch(errorCode) {
					case -110:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
						this.queueData.errorMsg='所选文件大小超出系统限制!';
						break;
					case -120:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
						this.queueData.errorMsg='所选文件大小异常!';
						break;
					case -130:
						//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
						this.queueData.errorMsg='所选文件类型不正确!';
						break;
				}
			},
			'onCancel' : function(file){
				//alert(file);
				alert(2);
			}
		});

		/**
		 *项目需求
		 *
		 **/
		$("#proDemandUpload").uploadify({//项目需求
			'height'        : 27,   
            'width'         : 80,    
            'buttonText'    : '选择附件',
            'queueID': 'fileQueue2',//队列的ID
            'queueSizeLimit':5,// 附件附列长度
			'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
			'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}?functionFlog=2',// 上传时请求的后台处理的controller
			'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
			'method':'post',  
			'folder': '',
			'preventCaching' : true,
			'fileTypeExts' :'*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws',
			'auto': true,
			'multi': true,//是否可多选
			'removeCompleted' : false,
			'successTimeout' : 55555,
			'fileSizeLimit'  : 2048*50,//文件大小
			'onUploadSuccess':function(file, data, response){
				$('#' + file.id).find('.data').html(' 上传完毕');
				$('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
				var cancel=$('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
				if (cancel) {
				   cancel.attr("rel", data);
				   cancel.click(function () {
					   var cancelData = cancel.attr("rel");
		               var  budgetMenuData = $('#budgetMenuData').val();
		               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
		               if(index != -1){
		            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
		            	   $('#budgetMenuData').val(budgetMenuData);
		               }
				   });
				}
			},
			'onSelectError':function(file, errorCode, errorMsg){
				switch(errorCode) {
					case -110:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
						this.queueData.errorMsg='所选文件大小超出系统限制!';
						break;
					case -120:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
						this.queueData.errorMsg='所选文件大小异常!';
						break;
					case -130:
						//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
						this.queueData.errorMsg='所选文件类型不正确!';
						break;
				}
			},
			'onCancel' : function(file){
				alert(file);
			}
		});

		/**
		 *其他资料
		 *
		**/
		$("#otherUpload").uploadify({//其资料
			'height'        : 27,   
            'width'         : 80,    
            'buttonText'    : '选择附件',
            'queueID': 'fileQueue3',//队列的ID
            'queueSizeLimit':5,// 附件附列长度
			'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
			'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}?functionFlog=3',// 上传时请求的后台处理的controller
			'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
			'method':'post',  
			'folder': '',
			'preventCaching' : true,
			'fileTypeExts' :'*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws',
			'auto': true,
			'multi': true,//是否可多选
			'removeCompleted' : false,
			'successTimeout' : 55555,
			'fileSizeLimit'  : 2048*50,
			'onUploadSuccess':function(file, data, response){
				$('#' + file.id).find('.data').html(' 上传完毕');
				$('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
				var cancel=$('.fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
				if (cancel) {
				   cancel.attr("rel", data);
				   cancel.click(function () {
					   var cancelData = cancel.attr("rel");
		               var  budgetMenuData = $('#budgetMenuData').val();
		               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
		               if(index != -1){
		            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
		            	   $('#budgetMenuData').val(budgetMenuData);
		               }
				   });
				}
			},
			'onSelectError':function(file, errorCode, errorMsg){
				switch(errorCode) {
					case -110:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
						this.queueData.errorMsg='所选文件大小超出系统限制!';
						break;
					case -120:
						//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
						this.queueData.errorMsg='所选文件大小异常!';
						break;
					case -130:
						//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
						this.queueData.errorMsg='所选文件类型不正确!';
						break;
				}
			},
			'onCancel' : function(file){
				alert(file);
			}
		});
	});

	//============
	function deleteFile(v,resId){
		var parent = v.parentNode;
		parent.parentNode.removeChild(parent);
		var  budgetMenuData = $('#budgetMenuData').val();
        var index = budgetMenuData.indexOf(","+resId)
        if(index != -1){
     	   budgetMenuData = budgetMenuData.replace(","+resId,"");
     	   $('#budgetMenuData').val(budgetMenuData);
        }
      //删除数据库中的文件信息
        $.ajax({
			type : "post",
			url : "${ctx}/business/projectmanage/deleteFile?resId="+resId,
			data : top.$("#addProjectsDataForm").serialize(),
			success : function(data){
				
			},
			error : function(data){
				alert("错误");
			}
		});
	}

	
	
</script>